package top.hcode.hoj.controller.oj;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.hcode.hoj.annotation.AnonApi;
import top.hcode.hoj.common.result.CommonResult;
import top.hcode.hoj.pojo.entity.user.Clazz;
import top.hcode.hoj.pojo.entity.user.Dep;
import top.hcode.hoj.pojo.entity.user.Leavels;
import top.hcode.hoj.pojo.entity.user.Major;
import top.hcode.hoj.service.oj.LeavelsService;

import java.util.List;

@RestController
@RequestMapping("/api/oj/getleavels")
public class LeavelsController {

    @Autowired
    private LeavelsService leavelsService;

    //此方法是前端注册的时候，下拉框获取数据的方法
    @GetMapping("/list")
    @AnonApi
    public CommonResult<List<Leavels>> getdeplist(@RequestParam(value = "oj", defaultValue = "ME") String oj) {
        return leavelsService.getdeplists(oj);
    }

    //此方法是后台管理员页面的年级的方法
    @GetMapping("/list_list")
    public CommonResult<List<Leavels>> getlist(@RequestParam(value = "oj", defaultValue = "ME") String oj) {
        return leavelsService.getlists(oj);
    }

    @PostMapping("/adddleavels")
    public CommonResult<Void> adddleavels(@RequestBody Leavels leavels) {
        return  leavelsService.adddleavels(leavels);
    }

    @PostMapping("/updatedleavels")
    public CommonResult<Void> updatedleavels(@RequestBody Leavels leavels) {
        return leavelsService.updatedleavels(leavels);
    }


    @DeleteMapping("/deleteleavels")
    public CommonResult<Void> deleteleavels(@RequestBody Leavels leavels) {
        return leavelsService.deleteleavels(leavels);
    }

}
